var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function i() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, 
    new i());
}), a = this && this.__decorate || function(t, e, o, i) {
    var n, a = arguments.length, s = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(t, e, o, i); else for (var l = t.length - 1; 0 <= l; l--) (n = t[l]) && (s = (a < 3 ? n(s) : 3 < a ? n(e, o, s) : n(e, o)) || s);
    return 3 < a && s && Object.defineProperty(e, o, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("PrefabView"), s = e("Global"), c = e("AudioManager"), l = e("GameData"), d = e("DataManager"), u = e("WebManager"), p = e("UIManager"), h = cc._decorator, f = h.ccclass, g = h.property, m = function(o) {
    function t() {
        var t = null !== o && o.apply(this, arguments) || this;
        return t.subContextView = null, t.world = null, t.auth = null, t.status = 1, t.authBtn = null, 
        t;
    }
    return i(t, o), t.prototype.onLoad = function() {
        this.subContextView && this.subContextView.node && this.subContextView.node.setContentSize(cc.winSize);
    }, t.prototype.onClickBack = function() {
        c.default.getInstance().playAudio("按钮2"), u.default.getInstance().sentLog("点击排行榜界面返回按键"), 
        this.hidePnl(), p.default.getInstance().showPnl("start");
    }, t.prototype.onClickFriend = function() {
        c.default.getInstance().playAudio("按钮2"), 2 != this.status && (this.status = 2, 
        this.doEffect());
    }, t.prototype.onClickWorld = function() {
        c.default.getInstance().playAudio("按钮2"), 1 != this.status && (this.status = 1, 
        this.doEffect());
    }, t.prototype.onEnable = function() {
        this.doEffect();
    }, t.prototype.onDisable = function() {
        var t, e;
        this.authBtn && this.authBtn.hide(), this.unscheduleAllCallbacks(), GA.PA && GA.PA.getOpenDataContext && GA.PA.getOpenDataContext().postMessage({
            messageType: 13
        }), GA.isPlatform(GA.Platform.Android) || null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.hideLoading) || void 0 === e || e.call(t, {}), 
        o.prototype.onDisable.call(this);
    }, t.prototype.start = function() {
        var t, e, o, i, n = this;
        this.subContextView._context && (t = cc.director.getWinSizeInPixels(), (e = this.subContextView._context.canvas) && (e.width = t.width, 
        e.height = t.height), this.subContextView.updateSubContextViewport());
        try {
            s.G.isAuth || (o = GA.PA.getSystemInfoSync().screenWidth / cc.view.getVisibleSize().width, 
            i = cc.v2(this.node.convertToNodeSpaceAR(this.auth.convertToWorldSpaceAR(cc.Vec2.ZERO))), 
            this.authBtn = GA.PA.createUserInfoButton({
                type: "text",
                text: "",
                image: "",
                style: {
                    left: (GA.PA.getSystemInfoSync().screenWidth + (2 * i.x - this.auth.width) * o) / 2,
                    top: (GA.PA.getSystemInfoSync().screenHeight - (2 * i.y + this.auth.height) * o) / 2,
                    width: this.auth.width * o,
                    height: this.auth.height * o,
                    backgroundColor: "",
                    borderColor: "",
                    borderWidth: 0,
                    borderRadius: 4,
                    color: "",
                    textAlign: "center",
                    fontSize: 16,
                    lineHeight: 40
                },
                withCredentials: !1
            }), this.authBtn && (this.authBtn.hide(), this.authBtn.onTap(function(t) {
                t.userInfo && (t = t.userInfo, l.GD.playerData.nickname = t.nickName, l.GD.playerData.icon = t.avatarUrl, 
                l.GD.playerData.sex = t.gender, d.default.getInstance().save(), s.G.isAuth = !0, 
                n.authBtn && n.authBtn.hide(), n.world && (n.world.active = !1), n.showWorld(), 
                u.default.getInstance().saveRank({
                    data: {
                        userid: GA.Info.uid,
                        level: l.GD.level,
                        nickname: t.nickName,
                        headicon: t.avatarUrl
                    }
                }));
            })));
        } catch (t) {}
        this.doEffect();
    }, t.prototype.doEffect = function() {
        2 == this.status ? this.showFriend() : 1 == this.status && (s.G.isAuth ? this.showWorld() : (this.subContextView && this.subContextView.node && (this.subContextView.node.active = !1), 
        this.world && (this.world.active = !0), this.authBtn && this.authBtn.show()));
    }, t.prototype.showFriend = function() {
        var t, e, o = this;
        this.subContextView && this.subContextView.node && (this.subContextView.node.active = !0, 
        this.subContextView.node.opacity = 0, GA.isPlatform(GA.Platform.Android) || null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.showLoading) || void 0 === e || e.call(t, {
            title: "",
            mask: !0
        }), this.scheduleOnce(function() {
            o.subContextView && o.subContextView.node ? cc.tween(o.subContextView.node).to(.5, {
                opacity: 255
            }).call(function() {
                var t, e;
                GA.isPlatform(GA.Platform.Android) || null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.hideLoading) || void 0 === e || e.call(t, {});
            }).start() : o.scheduleOnce(function() {
                var t, e;
                GA.isPlatform(GA.Platform.Android) || null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.hideLoading) || void 0 === e || e.call(t, {});
            }, .5);
        }, .04)), this.world && (this.world.active = !1), this.authBtn && this.authBtn.hide(), 
        GA.PA && GA.PA.getOpenDataContext && GA.PA.getOpenDataContext().postMessage({
            messageType: 11
        });
    }, t.prototype.showWorld = function() {
        var t, e, o = this;
        this.subContextView && this.subContextView.node && (this.subContextView.node.active = !0, 
        this.subContextView.node.opacity = 0, GA.isPlatform(GA.Platform.Android) || null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.showLoading) || void 0 === e || e.call(t, {
            title: "",
            mask: !0
        }), this.scheduleOnce(function() {
            o.subContextView && o.subContextView.node ? cc.tween(o.subContextView.node).to(.5, {
                opacity: 255
            }).call(function() {
                var t, e;
                GA.isPlatform(GA.Platform.Android) || null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.hideLoading) || void 0 === e || e.call(t, {});
            }).start() : o.scheduleOnce(function() {
                var t, e;
                GA.isPlatform(GA.Platform.Android) || null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.hideLoading) || void 0 === e || e.call(t, {});
            }, .5);
        }, .04)), this.world && (this.world.active = !1), this.authBtn && this.authBtn.hide(), 
        GA.PA && GA.PA.getOpenDataContext && GA.PA.getOpenDataContext().postMessage({
            messageType: 14
        });
    }, a([ g(cc.WXSubContextView) ], t.prototype, "subContextView", void 0), a([ g(cc.Node) ], t.prototype, "world", void 0), 
    a([ g(cc.Node) ], t.prototype, "auth", void 0), a([ f ], t);
}(r.default);

n.default = m;